/*日期格式转换*/
export function timestampToDate(timestamp) {
  const date = new Date(timestamp * 1000);
  const year = date.getFullYear();
  const month = ("0" + (date.getMonth() + 1)).slice(-2); // 月份是从0开始的，所以需要+1
  const day = ("0" + date.getDate()).slice(-2);
  const hours = ("0" + date.getHours()).slice(-2);
  const minutes = ("0" + date.getMinutes()).slice(-2);
  const seconds = ("0" + date.getSeconds()).slice(-2);

  return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
}

/*约见时间数据*/
export function generateOptions() {
	const options = [];
	const currentDate = new Date();
	for (let i = 0; i < 30; i++) {
		const futureDate = new Date(currentDate);
		futureDate.setDate(currentDate.getDate() + i);
		const year = futureDate.getFullYear();
		const month = String(futureDate.getMonth() + 1).padStart(2, '0'); // 月份从0开始，所以加1
		const day = String(futureDate.getDate()).padStart(2, '0');
		const dateStr = `${year}/${month}/${day}`;
		const option = {
			text: dateStr,
			value: `${i + 1}`,
			children: [
					{ text: '上午', value: `${i + 1}-1` },
					{ text: '下午', value: `${i + 1}-2` },
			],
		};
		options.push(option);
	}
	return options;
}
